#include"user.h"
#include"syscall.h"

int write(int fd, const char *buf, int len) {
    register int a0 asm("a0") = fd;
    register const char *a1 asm("a1") = buf;
    register int a2 asm("a2") = len;
    register int syscall_id asm("a7") = SYS_write;

    asm volatile("ecall"
                 : "+r"(a0)               // 输出值放在 a0
                 : "r"(a1), "r"(a2), "r"(syscall_id)
                 : "memory");
    //return a0;
    asm volatile("ret");
}
